﻿using Microsoft.Extensions.Logging;
using NuGet.Packaging;
using NuGet.Protocol.Core.Types;
using QuickGet.Core.Services;

namespace QuickGet.Core
{
    public record ReadPackageCommand(string Path);
    public class ReadPackage : NugetOperationBase
    {
        public ReadPackage(ILogger<ReadPackage> logger, SourceCacheContext sourceCache, INugetResourceResolver nugetResourceResolver, INugetSourceRepositoryResolver nugetSourceRepositoryResolver) : base(logger, sourceCache, nugetResourceResolver, nugetSourceRepositoryResolver)
        {
        }

        public async Task ExecuteAsync(ReadPackageCommand command, CancellationToken cancellationToken)
        {
            using var fs = new FileStream(command.Path, FileMode.Open);
            using var reader = new PackageArchiveReader(fs);

            var nuspecReader = await reader.GetNuspecReaderAsync(cancellationToken);
        }
    }
}
